import { ApiRes } from '@/types'
import { GoodsInfo } from '@/types'
import request from '@/utils/request'
import { defineStore } from 'pinia'

export default defineStore('goods', {
  state: () => ({
    // 商品详细信息
    info: {} as GoodsInfo,
    evaluate: {}
  }),
  actions: {
    async getGoodsInfo(id: string) {
      const res = await request.get<ApiRes<GoodsInfo>>('/goods', {
        params: {
          id,
        },
      })
      // console.log(res)
      this.info = res.data.result
    },
    // 获取商品评价信息 ，但是数据都是空的，就不渲染了
    // async getGoodsEvaluate(id: string){
    //   const res = await request.get('/goods/:id/evaluate', {
    //     params: {
    //       id
    //     }
    //   })
    //   console.log(res)
      
    // }
  },
})